/**
 * Created by mac on 2018/9/7.
 */
import { fromJS } from 'immutable';
import * as actionType from './actionType';

const defaultValue = fromJS({
    hotList: [{
        id: 1,
        imgUrl: 'https://upload.jianshu.io/collections/images/283250/%E6%BC%AB%E7%94%BB%E4%B8%93%E9%A2%98.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/64/h/64',
        title: '简书电影'
    },{
        id: 2,
        imgUrl: 'https://upload.jianshu.io/collections/images/13/%E5%95%8A.png?imageMogr2/auto-orient/strip|imageView2/1/w/64/h/64',
        title: '手绘'
    }],
    listData: [{
        id: 1,
        imgUrl: 'https://upload-images.jianshu.io/upload_images/2544184-f4dade8f9cd32ddd?imageMogr2/auto-orient/strip|imageView2/1/w/300/h/240',
        title: '如何过好一个人的生活，让自己获得成长？',
        desc: '我们每个人都会经历一些需要一个人度过的时间。 遇到伴侣前的孤寂，失恋痛苦后的彷徨，没人在身边的无助，朋友远离的寂寞，这些情况都可能出现在我们的人...'
    },{
        id: 2,
        imgUrl: 'https://upload-images.jianshu.io/upload_images/2544184-f4dade8f9cd32ddd?imageMogr2/auto-orient/strip|imageView2/1/w/300/h/240',
        title: '如何过好一个人的生活，让自己获得成长？',
        desc: '我们每个人都会经历一些需要一个人度过的时间。 遇到伴侣前的孤寂，失恋痛苦后的彷徨，没人在身边的无助，朋友远离的寂寞，这些情况都可能出现在我们的人...'
    }],
    showBackTop: false
});


export default (state = defaultValue, action) => {
    switch (action.type) {
        case actionType.GET_MORE_DATA:
            return state.set('listData', state.get('listData').concat(state.get('listData')));
        case actionType.SHOW_TOP:
            return state.set('showBackTop', true);
        case actionType.HIDDEN_TOP:
            return state.set('showBackTop', false);
        default:
            return state;
    }
}
